#include <bits/stdc++.h>
using namespace std;

int d[100010], v[100010], a[100010], p[100010];

int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    cin >> t;
    while (t--) {
        int n, m, t, vm, ans1 = 0, ans2 = 0;
        scanf("%d%d%d%d", &n, &m, &t, &vm);
        for (int i = 0; i < n; i++) scanf("%d%d%d", &d[i], &v[i], &a[i]);
        for (int i = 0; i < m; i++) scanf("%d", &p[i]);
        for (int i = 0; i < n; i++) {
            //printf("Car %d:\n", i);
            for (int j = 0; j < m; j++) {
                if (p[j] < d[i]) continue;
                double vt = sqrt(2.0*(p[j]-d[i])*a[i] + v[i]*v[i]);
                //printf("Speed %lf at detecter %d\n", vt, j);
                if (vt > vm) {
                    //printf("Over speed\n");
                    ans1++;
                }
            }
        }
        cout << ans1 << " " << m-2 << endl;
    }
    return 0;
}
